package com.cennavi.buss.service.imp;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.cennavi.buss.FeignMultipartSupportConfig;
import com.cennavi.buss.service.SoluService;
import com.cennavi.minemap.bean.MessageBean;

@FeignClient(value = "solu-service", fallback = SoluService.class, configuration = FeignMultipartSupportConfig.class)
public interface ISoluService {
	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/solu/add")
	public MessageBean insert(@RequestBody String json);

	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/solu/update")
	public MessageBean update(@RequestBody String json);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/delete/{id}")
	public MessageBean delete(@PathVariable(value = "id") int id);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/list/{userId}")
	public MessageBean queryByUserId(@PathVariable(value = "userId") int userId);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/nameList/{userId}")
	public MessageBean queryIdNameByUserId(@PathVariable(value = "userId") int userId);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/template/list")
	public MessageBean queryTemplate();

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/template2/list")
	public MessageBean queryTemplate2ByUserId();

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/edit/{id}")
	public MessageBean queryById(@PathVariable(value = "id") int id, @RequestParam(value = "token") String token);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/{id}")
	public MessageBean queryPublishById(@PathVariable(value = "id") int id, @RequestParam("token") String token);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/url/{url}")
	public MessageBean queryByUrl(@PathVariable(value = "url") String url, @RequestParam("token") String token);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/publish/{id}")
	public MessageBean publish(@PathVariable(value = "id") int id);
	
	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/solu/copy/{id}")
	public MessageBean copy(@PathVariable(value = "id") int id, @RequestBody String json);
	
	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/style/edit/id/{id}")
	public String queryStyle(@PathVariable(value = "id") int id);
	
	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/style/id/{id}")
	public String queryPublishStyle(@PathVariable(value = "id") int id);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/style/url/{url}")
	public String queryStyle(@PathVariable(value = "url") String url);
	
	//, consumes = MediaType.MULTIPART_FORM_DATA_VALUE
	@RequestMapping(method = RequestMethod.POST, value = "/service/solu/export")
	public ResponseEntity<Resource> download(@RequestParam("id") Integer id);
	
	@RequestMapping(method = RequestMethod.POST, value = "/service/solu/import",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
	public Integer upload(@RequestPart(value = "file") MultipartFile file, @RequestParam("userId") Integer userId);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/upload/findSolu/{uploadId}")
	public MessageBean querySoluListByUploadId(@PathVariable(value = "uploadId") Integer uploadId);
	
	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/upload/update/")
	public MessageBean updateUploadSolu(@RequestBody String json);
	
	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/test")
	public MessageBean test();
	
	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/solu/thumbnail/add")
	public @ResponseBody MessageBean insertThumbnail(@RequestBody String json);
	
	@RequestMapping(method = RequestMethod.POST, consumes = "application/x-www-form-urldecoded", value = "/service/solu/thumbnail/update")
	public @ResponseBody MessageBean updateThumbnail(@RequestBody String json);

	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/thumbnail/delete/{soluId}")
	public @ResponseBody MessageBean deleteThumbnail(@PathVariable(value = "soluId") int soluId);
	
	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/thumbnail/find/{soluId}")
	public @ResponseBody MessageBean queryThumbnailBySoluId(@PathVariable(value = "soluId") int soluId);
	
	@RequestMapping(method = RequestMethod.GET, value = "/service/solu/withPrefixLayer/{id}")
	public @ResponseBody MessageBean queryWithPrefixLayerById(@PathVariable(value = "id") int id, @RequestParam("token") String token);

}
